//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "tools\fn_GPSCoords.sqf"
#include <tmf_constants.h>
#include <tmf_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

private ["_pos","_xmap","_ymap","_gpsX","_compX","_zeroY","_coefdir","_wd_center","_gpsY","_compY"];
DEFAULT_PARAM(_pos,0,ARR_3(0,0,0));
// There is a built in command for that now.
// if (typename _pos == typename objNull) then {
	// _pos = getPos _pos;
// };
// _xmap = _pos select 0;
// _ymap = _pos select 1;

// // Adjusting offests depending on the world
// _zeroY = 0;
// _zeroX = 0;
// _coefdirX = 1;
// _coefdirY = 1;

// switch (worldName) do {
	// case "Chernarus": {
		// _wd_center = getArray (configFile>>"CfgWorlds">>worldName >> "centerPosition");
		// if (typename _wd_center == typename []) then {
			// if (count _wd_center > 1) then {
				// _zeroY = 2 * (_wd_center select 1);
			// };
		// };
		// _coefdirY = -1;
	// };
	// default {
		
	// };
// };

// _gpsX = floor ((_zeroX + (_coefdirX * _xmap)) / 100);
// _compX = "";
// if (_gpsX < 0) then { _gpsX = 1000 + _gpsX };
// if (_gpsX < 100) then { _compX = "0" };
// if (_gpsX < 10) then { _compX = "00" };

// _gpsY = floor ((_zeroY + (_coefdirY * _ymap)) / 100);
// _compY = "";
// if (_gpsY < 0) then { _gpsY = 1000 + _gpsY };
// if (_gpsY < 100) then {_compY = "0" };
// if (_gpsY < 10) then {_compY = "00" };

// TRACE_1("GPS Calc",ARR_8(_xmap,_ymap,_gpsX,_gpsY,_zeroX,_zeroY,_coefdirX,_coefdirY));
// _gpscoords = format["%1%2%3%4",_compX,_gpsX,_compY,_gpsY];

_gpscoords = mapGridPosition _pos;

TRACE("End",_gpscoords);
TMFPROFILERSTOP;
_gpscoords;
